package com.lihui.斐波那契数列;

import java.util.Enumeration;
import java.util.Scanner;

/**
 * 功能描述
 *
 * @author wileda
 * @date 2022/11/29  14:07
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int num = sc.nextInt();
            System.out.println(isFib(num));
        }
    }


    public static int isFib(int num){
        int a = 0,b = 1;
        int n = 0;
        while(b < num){
            n = a + b;
            a = b;
            b = n;
        }
       int min = Math.min(num - a,b - num);
        return min;
    }
}
